using Json;

namespace MobilePal.Rules
{
    #region Imported Namespaces

    using System.Xml.Serialization;
    using Diagnostics.Annotations;
    using Collections;
    using State;

    #endregion

    /// <summary>
    /// Describes and manipulates the activity rule.
    /// </summary>
    [UsedImplicitly(ImplicitUseFlags.IncludeMembers)]
    public abstract class ActivityRule
    {
        #region Constants and Fields

        [NotNull] private ActivityCollection _activities = new ActivityCollection();

        [NotNull] private ActivityCategoryCollection _categories = new ActivityCategoryCollection();

        [NotNull] private ActivityCollection _excludedActivities = new ActivityCollection();

        [NotNull] private ActivityCategoryCollection _excludedCategories = new ActivityCategoryCollection();

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ActivityRule"/> class.
        /// </summary>
        protected ActivityRule()
        {
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="ActivityRule"/> class.
        /// </summary>
        /// <param name="ruleName">
        /// Name of the rule.
        /// </param>
        protected ActivityRule(string ruleName)
            : this()
        {
            Name = ruleName;
        }

        #endregion


        #region Properties

        private readonly ObservableCollection<Activity> _processedActivities = new ObservableCollection<Activity>();

        /// <summary>
        /// Gets the processed activities.
        /// </summary>
        /// <value>The processed activities.</value>
        [JsonIgnore]
        public ObservableCollection<Activity> ProcessedActivities
        {
            get { return _processedActivities; }
        }


        /// <summary>
        /// Gets a collection of activities.
        /// </summary>
        /// <value>
        /// A collection of activities.
        /// </value>
        [NotNull]
        public ActivityCollection Activities
        {
            get { return _activities; }
            set { _activities = value; }
        }


        /// <summary>
        /// Gets a collection of categories.
        /// </summary>
        /// <value>
        /// A collection of categories.
        /// </value>
        [NotNull]
        public ActivityCategoryCollection Categories
        {
            get { return _categories; }
            set { _categories = value; }

        }


        /// <summary>
        /// Gets a collection of excluded activities.
        /// </summary>
        /// <value>
        /// A collection of excluded activities.
        /// </value>
        [NotNull]
        public ActivityCollection ExcludedActivities
        {
            get { return _excludedActivities; }
            set { _excludedActivities = value; }

        }

        /// <summary>
        /// Gets the excluded categories.
        /// </summary>
        /// <value>
        /// The excluded categories.
        /// </value>
        [NotNull]
        public ActivityCategoryCollection ExcludedCategories
        {
            get { return _excludedCategories; }
            set { _excludedCategories = value; }

        }


        /// <summary>
        /// Gets or sets the rule name.
        /// </summary>
        /// <value>
        /// The rule name.
        /// </value>
        [XmlAttribute]
        public string Name { get; set; }

        #endregion
    }
}